<template>
	<view>
		<view class="andIso acea-row row-center-wrapper">
			<view class="inputs acea-row row-center-wrapper">
				<image src="../../static/so.png" mode=""></image>
				<input type="text" value="" @input="inputshg" placeholder="#请输入关键词#" placeholder-class="oi" />
			</view>
		</view>
		<view class="biaotis">
			<view class="title">{{dataLis1.info.name}}</view>
			<view class="info">{{dataLis1.info.description}}</view>
		</view>
		<view class="swipers">
			<swiper class="swiper" indicator-color="rgba(255,255,255,.6)" indicator-active-color="#fff" active-class='swioe'
			 next-margin='30px' circular='true'>
				<swiper-item v-for="val in dataLis1.banner" @click="tiaos(val.url)">
					<view class="swiper-item uni-bg-red">
						<image :src="val.image" mode="aspectFill"></image>
					</view>
				</swiper-item>


			</swiper>
		</view>
		<!-- 问题list -->
		<view class="wenTiwai">
			<view class="numSet acea-row row-between-wrapper">
				<view class="num">共有{{dataLis1.count}}条问题</view>
				<view class="ritwen">
					<view class="acea-row row-center-wrapper" @tap="dian">
						<view>{{quanb}}</view>
						<image src="../../static/xiazia.png"></image>
					</view>
					<view class="xuantin" v-if="setiuc">
						<view @tap="qiehuan(2,'全部问题')">全部问题</view>
						<view @tap="qiehuan(val.id,val.name)" v-for="val in dataLis1.cate">{{val.name}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="wtList" @tap="wenxq(val.id,val.category_id)" v-for="val in dataLis1.list">
			<view class="acea-row imgsgd">
				<image src="../../static/ksi.png"></image>
				<view class="title textline1">{{val.post_title}}</view>

			</view>
			<view class="huzyais acea-row row-between-wrapper">
				<view class="info" :class="val.images==''?'info2':val.images.length == 0 ? 'info2':''">
					{{val.post_content}}
				</view>
				<image mode="aspectFill" v-if="val.images!='' || val.images.length != 0" :src="val.images[0]"></image>
			</view>

		</view>
		<view style="color: #999999;height: 100rpx; font-size: 26rpx;" class="acea-row row-center-wrapper"><text>已经到底了</text></view>
		<view style="height: 140rpx;"></view>
		<view class="tiwen acea-row row-center-wrapper" @click="tiwen">
			<image src="../../static/wen.png"></image>
			<view>提问</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				setiuc: false,
				page: 1,
				limit: 100,
				dataLis1: {

				},
				key: '',
				quanb: "全部问题",
				cid: 2,

			}
		},
		onLoad() {
		var jweixin = require('jweixin-module')
		var that = this
		console.log(jweixin)
			var urls = window.location.href
		this.$api('/portal/index/jsconfig', {datas:{url:urls}}, function(res) {
			console.log(res)
			var s = res.data.data
			jweixin.config({
			    debug: false,
			    appId: s.appId,
			    timestamp: s.timestamp,
			    nonceStr: s.nonceStr,
			    signature:s.signature,
			    jsApiList: ["updateTimelineShareData","updateAppMessageShareData"]
			});
			jweixin.ready(function(){
			jweixin.updateTimelineShareData({
					title: '海绵医学院', // 分享标题
				    link: urls, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
				    imgUrl: 'http://api.haimiantv.cn/upload/default/20200426/86ea4921376b6656f24fbb40e674b361.png', // 分享图标
				    success: function () {
				      // 设置成功
					  console.log(1)

				    }
			})
			jweixin.updateAppMessageShareData({
				title: '海绵医学院', // 分享标题
				desc: '一个专业/有态度的医学直播交流平台', // 分享描述
				link: urls, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
				imgUrl: 'http://api.haimiantv.cn/upload/default/20200426/86ea4921376b6656f24fbb40e674b361.png', // 分享图标
				success: function () {
				  // 设置成功
				}
			  })



			})
			jweixin.error(function(res){
				console.log(res)
			})
		})
		},
		onShow() {
			console.log(1)
		},
		created() {

			this.riuc()
			console.log(3)

		},
		methods: {
			tiaos(e) {
				console.log(e)
				if (e == '' || e == undefined) {
					return false
				}
				window.location.href = e
			},
			riuc() {
				var that = this
				var datas = {
					page: this.page,
					limit: this.limit,
					key: this.key,
					cid: this.cid
				}

				this.$api('/portal/index/wenda', {
					datas: datas
				}, function(res) {
					console.log(res)
					if (res.data.data.length == 0) {
						uni.showToast({
							title: '什么都没有 ~',
							icon: 'none',
							duration: 1500
						})
					}
					that.dataLis1 = res.data.data
				})
			},
			inputshg(e) {
				console.log(e)
				var key = e.detail.value
				this.key = key
				this.riuc()

			},
			dian() {
				this.setiuc = !this.setiuc
			},
			qiehuan(id, name) {
				this.setiuc = !this.setiuc
				this.quanb = name
				this.cid = id
				this.riuc()
			},
			wenxq(e, cid) {
				uni.navigateTo({
					url: '../index-wxq/index-wxq?id=' + e + "&cid=" + cid
				})
			},
			tiwen() {
				uni.navigateTo({
					url: '../tiwen/tiwen'
				})
			}
		}
	}
</script>

<style>
	@import url("./index-jrwd.css");
</style>
